package cn.test;

import android.app.Activity;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.ServiceConnection;
import android.os.Bundle;
import android.os.IBinder;
import android.os.RemoteException;

import com.shine.systemmanage.aidl.IShineSystemManage;

public class MainActivity extends Activity {
//modify by sjj
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);

		systemManagerConnection = new SystemManagerConnection();
		Intent service = new Intent("com.shine.systemmanage.aidl");
		bindService(service, systemManagerConnection, Context.BIND_AUTO_CREATE);
		
		
	}

	private IShineSystemManage myService;
	private SystemManagerConnection systemManagerConnection;

	/**
	 * 对IShineSystemManage的连接 add by sjj 2013.5.6
	 * 
	 * @author 宋疆疆
	 * 
	 */
	private class SystemManagerConnection implements ServiceConnection {

		@Override
		public void onServiceConnected(ComponentName name, IBinder service) {
			// TODO Auto-generated method stub
			myService = IShineSystemManage.Stub.asInterface(service);
			if (null == myService) {
			} else {

				try {
					myService.EnableDisplay();
					new Thread() {
						public void run() {
							try {
								myService.SetPanelSolution(1280, 720);
							} catch (RemoteException e) {
								// TODO Auto-generated catch block
								e.printStackTrace();
							}
						};
					}.start();
				} catch (RemoteException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
			}
		}

		@Override
		public void onServiceDisconnected(ComponentName name) {
			// TODO Auto-generated method stub

		}

	}

}
